package com.ny.demo516;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {

        Emp emp1 = new Emp();
        emp1.setNumber("1001");
        emp1.setName("小明");
        emp1.setAge(20);
//用了toString 方法 直接输出对象名
//        System.out.println(emp1);

        Emp emp2 = new Emp();
        emp2.setNumber("1002");
        emp2.setName("小王");
        emp2.setAge(18);

        Emp emp3 = new Emp("1003","后裔",15);
//把员工信息添加到集合 List ArrayList
        List<Emp> list = new ArrayList();

        list.add(emp1);
        list.add(emp2);
        list.add(emp3);
        //查询所有的员工
//        System.out.println(list.get(0));

        for(int i=0;i<list.size();i++){
            System.out.println(list.get(i));
        }
        //查询某个员工的信息 例1001

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要查询员工的工号");
        int a = scanner.nextInt();
        if(a>=1001&&a<=1003) {
            switch (a) {
                case 1001:
                    System.out.println(list.get(0));
                    break;
                case 1002:
                    System.out.println(list.get(1));
                    break;
                case 1003:
                    System.out.println(list.get(2));
                    break;
            }
        }else {

            System.out.println("请输入已录入的员工工号");
        }
    }

}
